package com.ithzl.capacity.controller;

import com.ithzl.capacity.pojo.EntryForm;
import com.ithzl.capacity.pojo.EntryForm_02;
import com.ithzl.capacity.pojo.RESTful.RestBean;
import com.ithzl.capacity.pojo.dto.EvaluateBriefDTO;
import com.ithzl.capacity.pojo.dto.EvaluatePageDTO;
import com.ithzl.capacity.pojo.dto.WorksControlBrief;
import com.ithzl.capacity.pojo.dto.WorksPageDTO;
import com.ithzl.capacity.service.WorksService;
import jakarta.websocket.server.PathParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/works")
public class WorksController {


    @Autowired
    WorksService worksService;



    @PostMapping("/getList")
    public RestBean selectWorksList(WorksPageDTO worksPageDTO){
        List<WorksControlBrief>  worksControlBriefList = worksService.selectWorksList(worksPageDTO);
        return RestBean.succeed(worksControlBriefList);
    }

    @GetMapping("/details")
    public RestBean selectWorksDetails(@PathParam("entryFormId") int entryFormId){
        EntryForm entryForm=worksService.selectWorksById(entryFormId);
        return RestBean.succeed(entryForm);
    }

    //TODO 评价管理

    /**
     * 获取评价简信息列表
     * @param evaluatePageDTO
     * @return
     */
    @PostMapping("/getEvaluateList")
    public RestBean selectEvaluateList(EvaluatePageDTO evaluatePageDTO){
        List<EvaluateBriefDTO> evaluateBriefDTOList= worksService.selectEvaluateList(evaluatePageDTO);
        return RestBean.succeed(evaluateBriefDTOList);
    }

    @GetMapping("/evaluate")
    public RestBean selectEvaluate(@PathParam("entryFormId") int entryFormId){
        EntryForm_02 entryForm_02=worksService.selectEvaluate(entryFormId);
        return RestBean.succeed(entryForm_02);
    }
}
